package com.zhang.family_doctor.controller;

import com.github.pagehelper.PageInfo;
import com.zhang.family_doctor.dto.DoctorDto;
import com.zhang.family_doctor.dto.DoctorRoleDto;
import com.zhang.family_doctor.entity.R;
import com.zhang.family_doctor.service.DoctorService;
import com.zhang.family_doctor.vo.DoctorAllVO;
import com.zhang.family_doctor.vo.DoctorVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 医生端  |后台系统
 */
@Api(tags = "医生相关接口")
@RestController
@RequestMapping("/doctor")
@Slf4j
public class DoctorController {

    @Autowired
    private DoctorService doctorService;

    @ApiOperation("后台登录接口")
    @GetMapping("/login")
    public R login(String phone , String password){
        log.info("后台系统登录：{}",phone,password);
        return doctorService.login(phone,password);
    }

    @ApiOperation("后台登录接口共给第三方接口token")
    @GetMapping("/logins")
    public String logins(String phone , String password){
        log.info("后台系统登录：{}",phone,password);
        return doctorService.logins(phone,password);
    }

    @ApiOperation("医生端登录")
    @GetMapping("/loginDoctor")
    public R<Map> loginDoctor(String phone , String password){
        log.info("医生端登录：{}",phone,password);
        return doctorService.loginDoctor(phone,password);
    }

    @ApiOperation("新增医生")
    @PostMapping("/saveDoctor")
    public R saveDoctor(@RequestBody DoctorRoleDto doctorRoleDto, HttpServletRequest request){
        log.info("新增医生：{}",doctorRoleDto);
        return doctorService.saveDoctor(doctorRoleDto,request);
    }

    @ApiOperation("编辑医生信息")
    @PostMapping("/updateDoctor")
    public R updateDoctor(@RequestBody DoctorRoleDto doctorRoleDto , HttpServletRequest request){
        log.info("编辑医生信息：{}",doctorRoleDto);
        return doctorService.updateDoctor(doctorRoleDto,request);
    }

    @ApiOperation("查看分页的医生")
    @PostMapping("/getAllDoctor")
    public R<PageInfo<DoctorAllVO>> getAllDoctor(@RequestBody DoctorDto doctorDto){
        log.info("查看分页的医生：");
        return doctorService.getAllDoctor(doctorDto);
    }

    @ApiOperation("根据id删除医生")
    @DeleteMapping("/deleteDoctor")
    public R<String> deleteDoctor(Integer id){
        log.info("根据id删除医生：{}",id);
        return doctorService.deleteDoctor(id);
    }


    @ApiOperation("查看医生详情")
    @GetMapping("/getDoctorDetails")
    public R<DoctorVO> getDoctorDetails(Integer id){
        log.info("查看医生详情：{}",id);
        return doctorService.getDoctorDetails(id);
    }


//    @PostMapping("/saveAll")
//    public R<String> saveAll(@RequestBody List<DoctorRole> doctorRoleList){
//        log.info("医生单个新增或多个新增角色：{}",doctorRoleList);
//        return doctorService.saveAll(doctorRoleList);
//    }
//
//
//    @PostMapping("/updateList")
//    public R<String> updateList(@RequestBody List<DoctorRole> doctorRoleList){
//        log.info("批量修改医生角色：{}",doctorRoleList);
//        return doctorService.updateList(doctorRoleList);
//    }

}
